package de.urbiworx.sugar;

import org.xml.sax.Attributes;

import com.google.inject.Module;

public class AdditionalModuleEntry {
	private Module module;
	private int line;
	private String filename;
	
	public AdditionalModuleEntry(Attributes atts,int line, String filename) {
		String className=atts.getValue("class");
		try {
			Class clazz = getClass().getClassLoader().loadClass(className);
			module=(Module)clazz.newInstance();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new SugarException("An error occured while instanciating class (class not found):"+className+" Filename:"+filename+" Line:"+line);			
		}
		catch (InstantiationException e1) {
			e1.printStackTrace();
			throw new SugarException("An error occured while instanciating class (InstantiationException):"+className+" Filename:"+filename+" Line:"+line);
		}
		catch (IllegalAccessException e2) {
			e2.printStackTrace();
			throw new SugarException("An error occured while instanciating class (IllegalAccessException):"+className+" Filename:"+filename+" Line:"+line);
		}
		
	}
	
	public int getLine() {
		return line;
	}

	public void setLine(int line) {
		this.line = line;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}
	
	public Module getModule() {
		return module;
	}
}
